Skip to content

Add Vizard visualization support for MuJoCo multi-body scenes#1287

Open
ReeceHumphreys wants to merge 6 commits intodevelopfrom
feature/mujoco-vizard
Open

Add Vizard visualization support for MuJoCo multi-body scenes#1287
ReeceHumphreys wants to merge 6 commits intodevelopfrom
feature/mujoco-vizard

Conversation

@ReeceHumphreys
Copy link
Copy Markdown
Contributor

Description

TODO

Verification

TODO

Documentation

TODO

Future work

TODO

@ReeceHumphreys ReeceHumphreys self-assigned this Feb 24, 2026
@ReeceHumphreys ReeceHumphreys added the enhancement New feature or request label Feb 24, 2026
@ReeceHumphreys
Copy link
Copy Markdown
Contributor Author

@juan-g-bonilla definitely want your feedback on this as the resident MuJoCo guy. Want to make sure not doing anything dumb here haha.

# Position offset in body frame
offset = list(geom.pos)

# Convert quaternion (w, x, y, z) to 3-2-1 Euler angles (z, y, x)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using EP2Euler321 from RigidBodyKinematics.py (but double check that function is doing what you expect!).

Copy link
Copy Markdown
Contributor

@juan-g-bonilla juan-g-bonilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been summoned! Great PR. I left a lot of comments because reviewing PRs is my happy place, but it's mostly about how I would write some code rather than any "mistakes". Feel free to accept, ignore, or argue about any of my comments (I love an argument).

@ReeceHumphreys ReeceHumphreys force-pushed the feature/mujoco-vizard branch from ffa76e5 to 7d32601 Compare April 2, 2026 19:05
@ReeceHumphreys ReeceHumphreys force-pushed the feature/mujoco-vizard branch 2 times, most recently from 39092a8 to aee2fb1 Compare April 10, 2026 04:55
@ReeceHumphreys ReeceHumphreys force-pushed the feature/mujoco-vizard branch from aee2fb1 to 6bc5dec Compare April 10, 2026 04:58
Copy link
Copy Markdown
Contributor

@juan-g-bonilla juan-g-bonilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work as usual!

Comment on lines +45 to +48
std::vector<double> size = std::vector<double>(3); ///< Size parameters (3 elements).
std::vector<double> pos = std::vector<double>(3); ///< Position in body frame (3 elements).
std::vector<double> quat = std::vector<double>(4); ///< Quaternion in body frame (4 elements: w, x, y, z).
std::vector<double> rgba = std::vector<double>(4); ///< Color (4 elements, 0-1 range).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do:

std::vector<double> size(3);

if you want shorter syntax

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, what was the rational for keeping these as std::vector instead of std::array?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That syntax suggestion is incorrect in this context. That is only valid for local variable declarations, not in-class default member initializers. The {3} would be parsed as an initializer-list constructor call producing a 1-element vector containing 3.0, not a 3-element zero-initialized vector.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for the vector is to be consistent with SWIG. SWIG exposes MJGeomInfo to Python via %template() std::vector<double>. Would be incorrect to do an array.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right:

std::vector<double> size(3);

actually makes for some pretty vexing parsing.

Still, if you wanted to use std::array you could do it in SWIG by doing:

%include "swig_std_array.i"

@ReeceHumphreys ReeceHumphreys marked this pull request as ready for review April 12, 2026 21:16
@ReeceHumphreys ReeceHumphreys requested a review from a team as a code owner April 12, 2026 21:16
@ReeceHumphreys
Copy link
Copy Markdown
Contributor Author

Great work as usual!

Thanks @juan-g-bonilla , I appreciate your SWIG expertise!

Copy link
Copy Markdown
Contributor

@juan-g-bonilla juan-g-bonilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes!

Comment on lines +1161 to 1162
freeBodyNames = [name for name in bodyNames if sc.getBodyParentName(name) == "world"]
if not freeBodyNames:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could rename variable to: topLevelBodyNames (and other variables below that still refer to these as "free".

@ReeceHumphreys ReeceHumphreys moved this to 👀 In review in Basilisk Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

Support MuJoCo message passthrough to Vizard

2 participants